package com.ai.web.app;

import java.net.URL;
import java.util.Properties;

import org.apache.log4j.Logger;


public class AppContext {

	private static Logger logger = Logger.getLogger(AppContext.class);
	
	public static String apiKey = "";
	public static String secretKey = "";
	public static String appVersion = "";
	
	static {
		try {
			URL fileUrl = Thread.currentThread().getContextClassLoader().getResource("app.properties");
			
			Properties prop = new Properties();
			prop.load(fileUrl.openStream());
			apiKey = (String) prop.get("apiKey");
			secretKey = (String) prop.get("secretKey");
			appVersion = (String) prop.get("appVersion");
			
		} catch(Exception e) {
			logger.error(e.getMessage(), e);
		}
	}
	
	public static String getAppVersionByFile() {
	    try {
	        URL fileUrl = Thread.currentThread().getContextClassLoader().getResource("app.properties");
	        Properties prop = new Properties();
            prop.load(fileUrl.openStream());
            return (String) prop.get("appVersion");
	    }catch(Exception e) {
            logger.error(e.getMessage(), e);
        }
	    return null;
	}
	
	
	
	
}
